import React from "react";
import { Button } from "antd";
import { useSelector,useDispatch } from "react-redux";
import { increment ,decrement} from "../store/slices/testSlice";
// import { increment } from "../store/actions/testAction";

export default function TestRedux() {
    let count = useSelector((state) => state.test.count);
    let dispatch = useDispatch();
    const handleAdd = () => {
        dispatch(increment(10));
    }
    const handleDec = () => {
        dispatch(decrement(10));
    }
    return (
        <div>
            <p>计数器：{count}</p>
            <Button type="primary" onClick={handleAdd}>加1</Button>
            <Button type="primary" onClick={handleDec}>减1</Button>
        </div>
    );
}
